window.onload = function(){
  
  //字段类型单选
  var radios = document.getElementsByName("type");
  
  //名称输入框
  var name = document.getElementById('name');
  
  //可选值输入框
  var option_input = document.getElementById('content');
  
  //当前值输入框
  //var current_input = document.getElementById('current_value');

  //输入框禁用
  if('0'!=getRadioValue()){
    option_input.disabled = "disabled";
  }
  
  //========
  //取值方法
  //========
  function getRadioValue(){
      
      for(var i=0;i<radios.length;i++){
        if(radios[i].checked==true){
          value=radios[i].value;
          return value;
        }
      }
  }
  
  //========
  //隐显控制
  //========
  function switchOption(){
    switch(getRadioValue()){
        case '0': //单选
          option_input.disabled = false;
          name.focus();
        break;
        
        case '1': //单行时候禁用可选值和当前值
          option_input.value ="";
          option_input.disabled = "disabled";
          
          //替换内容为单行文本输入框类型
          //current_input.disabled = "disabled";
          name.focus();

        break;
        
        case '2': //多行时候禁用可选值和当前值
          option_input.value ="";
          option_input.disabled = "disabled";
          
          //替换内容为多行文本输入框
          //current_input.disabled = "disabled";
          name.focus();
        break;
        
        default:
        break;
    }
  }
  
  //========
  //选择监听
  //========
  for (var i=0;i<radios.length;i++)
  {
    addListener(radios[i], "click", switchOption);
  }
}